﻿package mortal.game.view.common.guide.stepOperater
{
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.guide.data.*;
    import mortal.game.view.mainUI.Navbar.*;
    import mortal.mvc.core.*;

    public class AutoGuideRightDownIconSteper extends AutoGuideStepBase implements IAutoGuideSteper
    {
        private var _opBtn:DisplayObject;

        public function AutoGuideRightDownIconSteper()
        {
            return;
        }// end function

        public function guide(param1:AutoGuideData, param2:Window = null) : void
        {
            if (param1 == null || param1.guideTypeValue == null || param1.guideTypeValue == "")
            {
                return;
            }
            if (_working)
            {
                this.stop();
            }
            _data = param1;
            var _loc_3:* = (GameController.navbar.view as NavbarModule).getNavbarIcon(String(param1.guideTypeValue));
            if (_loc_3 == null)
            {
                return;
            }
            if (param1.needMask)
            {
                showMask(LayerManager.highestLayer, _loc_3);
            }
            if (param1.needLightMask)
            {
                showLightMask(LayerManager.highestLayer, _loc_3);
            }
            if (param1.needCircleEffect)
            {
                showCircleEffect(LayerManager.highestLayer, _loc_3);
            }
            this._opBtn = _loc_3;
            arrow.direction = param1.arrowDirection;
            arrow.label = param1.arrowTips;
            LayerManager.highestLayer.addChild(arrow);
            this.everyTime(null);
            if (_updatePlaceTiemr == null)
            {
                _updatePlaceTiemr = new Timer(200);
                _updatePlaceTiemr.addEventListener(TimerEvent.TIMER, this.everyTime);
            }
            else
            {
                _updatePlaceTiemr.stop();
            }
            _updatePlaceTiemr.start();
            if (param1.clickType == AutoGuideClickType.Click)
            {
                _loc_3.addEventListener(MouseEvent.CLICK, this.clickOpBtnHandler, false, 10000000);
            }
            else
            {
                _loc_3.addEventListener(MouseEvent.DOUBLE_CLICK, this.clickOpBtnHandler, false, 10000000);
            }
            super.setData(param1, null, _loc_3);
            Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuide_RightDownIcon));
            return;
        }// end function

        private function everyTime(event:TimerEvent) : void
        {
            if (this._opBtn == null)
            {
                return;
            }
            var _loc_2:* = this._opBtn.localToGlobal(GameConst.yellowPoint);
            arrow.x = _loc_2.x + 21;
            arrow.y = _loc_2.y - 8;
            return;
        }// end function

        private function clickOpBtnHandler(event:MouseEvent) : void
        {
            var _loc_2:* = event.currentTarget as DisplayObject;
            _loc_2.removeEventListener(MouseEvent.CLICK, this.clickOpBtnHandler);
            _loc_2.removeEventListener(MouseEvent.DOUBLE_CLICK, this.clickOpBtnHandler);
            this.stop(_data);
            return;
        }// end function

        override protected function guideTimerOut() : void
        {
            super.guideTimerOut();
            Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuide_RightDownIconEnd));
            return;
        }// end function

        override public function stop(param1:AutoGuideData = null) : void
        {
            super.stop(param1);
            if (param1 != null)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideStepEnd, param1));
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuide_RightDownIconEnd));
            return;
        }// end function

    }
}
